﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Memcached.ClientLibrary;

namespace KingSite.Library.Cache.MemcachedWrapper {
    public class MemcachedWrapper : ICache {

        private MemcachedClient m;

        public MemcachedWrapper() {
            m = new MemcachedClient();
        }

        public void Add(string key, object value) {
            m.Add(key, value);
        }

        public void Add(string key, object value, int seconds) {
            m.Add(key, value, DateTime.Now.AddSeconds(seconds));
        }

        public object Get(string key) {
            return m.Get(key);
        }

        public void Remove(string key) {
            m.Delete(key);
        }

        public void Clear() {
            m.FlushAll();
        }
    }
}
